package leetcode.code1790;

import leetcode.IDebug;

public class Solution implements IDebug {

	public boolean areAlmostEqual(String s1, String s2) {
		char[] cs1 = s1.toCharArray();
		char[] cs2 = s2.toCharArray();
		int len = cs1.length;
		int diff = 0;
		int d1 = -1, d2 = -1;
		for (int i = 0; i < len; i++) {
			if (cs1[i] != cs2[i]) {
				diff++;
				if (diff > 2) {
					return false;
				}
				if (diff == 1) {
					d1 = i;
				} else {
					d2 = i;
				}
			}
		}
		if (diff == 1) {
			return false;
		} else if (diff == 0) {
			return true;
		} else {
			return cs1[d1] == cs2[d2] && cs1[d2] == cs2[d1];
		}
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
